package com.xm.settlement.service.impl;
import com.baomidou.framework.service.impl.SuperServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;
import com.xm.settlement.commons.utils.PageInfo;
import com.xm.settlement.mapper.AppGoodsManageMapper;
import com.xm.settlement.model.AppGoodsManage;
import com.xm.settlement.service.IAppGoodsManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by Administrator on 2017/3/2.
 */
@Service
public class AppGoodsManageServiceImpl extends SuperServiceImpl<AppGoodsManageMapper,AppGoodsManage> implements IAppGoodsManageService {

    @Autowired
    private AppGoodsManageMapper appGoodsManageMapper;

    @Autowired
    private IAppGoodsManageService appGoodsManageService;

    @Override
    public void selectDataGrid(PageInfo pageInfo,Long Lid) {
        Page<AppGoodsManage> page = new Page<AppGoodsManage>(pageInfo.getNowpage(), pageInfo.getSize());
        List<AppGoodsManage> list = appGoodsManageMapper.selectAppGoodsManageList(page,Lid);
        pageInfo.setRows(list);
        pageInfo.setTotal(page.getTotal());
    }

    @Override
    public Integer addForm(AppGoodsManage appGoodsManage,Long goodsCode){
        Long gs = appGoodsManageMapper.selectGoodsCode(goodsCode);
        if (goodsCode.equals(gs)){
            return 0; //"商品编码重复"
        }else {
            appGoodsManageService.insert(appGoodsManage);
            return 1;//"添加成功"
        }
    }
}
